import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class LanguageProvider extends ChangeNotifier {
  String _locale = 'en'; // 默认语言

  String get locale => getLocale();

  void setLocale(String newLocale) {
    _locale = newLocale;
    SpUtil.putString('locale', _locale);
    notifyListeners();
  }

  String getLocale() {
    if (SpUtil.getString('locale') != null &&
        SpUtil.getString('locale')!.isNotEmpty) {
      return SpUtil.getString('locale')!;
    } else {
      return _locale;
    }
  }

  String translate(String key) {
    switch (_locale) {
      case 'zh':
        return LocaleStrings.zh[key] ?? key;
      default:
        return LocaleStrings.en[key] ?? key;
    }
  }
}

class LocaleStrings {
  static Map<String, String> en = {
    'My': 'My',
    'Account Management': 'Account Management',
    'Key Management': 'Key Management',
    'MemberShip Management': 'MemberShip Management',
    'language': 'language',
    'Theme': 'Theme',
    'About': 'About',
    'Log out': 'Log out',
    'Log out success': 'Log out success',
    'History List': 'History List',
    'History Detail': 'History Detail',
    'Select Language': 'Select Language',
    'English': 'English',
    'Chinese': 'Chinese',
    'Authentication failure': 'Authentication failure',
    'Add Key': 'Add Key',
    'Please enter a key': 'Please enter a key',
    'Please enter a name': 'Please enter a name',
    'New Secret Key': 'New Secret Key',
    'New Name': 'New Name',
    'copy success': 'copy success',
    'Register': 'Register',
    'Login': 'Login',
    'Reset Password': 'Reset Password',
    'Main Page': 'Main Page',
    'Encrypt': 'Encrypt',
    'Decrypt': 'Decrypt',
    'Single File': 'Single File',
    'Batch File': 'Batch File',
    'Next Step': 'Next Step',
    'finish': 'finish',
    'Start': 'Start',
    'index': 'index',
    'history': 'history',
    'my': 'my',
    'Select files': 'Select files',
    'Please select the file first': 'Please select the file first',
    'Please select one key first': 'Please select onr key first',
    'Delete Account': 'Delete Account',
    'Cancel': 'Cancel',
    'Confirm': 'Confirm',
    'Random generation': 'Random generation',
    'Please select a key': 'Please select a key',
    'The key must contain 16 characters': 'The key must contain 16 characters',
    'Select key': 'Select key',
    'Select algorithm': 'Select algorithm',
    'Introducing our cutting-edge application, designed with a comprehensive set of features to enhance user experience and security. Our app offers a seamless registration and login process, ensuring a smooth start for new users. With robust user account management, users can effortlessly control their personal information and settings, including password resets and customization preferences.\n\nFor a premium experience, we provide a membership subscription service that eliminates advertisements, supporting our monetization efforts. Key management is simplified, allowing users to add, select, and remove encryption keys with ease. Our app empowers users to encrypt and decrypt both single and batch files, ensuring their data is always protected. Activity history is meticulously recorded, giving users a clear overview of their encryption and decryption activities.\n\nWe understand the importance of a user-friendly interface, which is why our app is designed with usability in mind, requiring minimal training for effective navigation. Performance is a cornerstone of our app, with swift responsiveness and efficient load handling across various scenarios. Scalability is also a key feature, allowing our app to grow with our user base without compromising performance.\n\nSecurity is at the heart of our app, with robust measures in place to protect against unauthorized access and data breaches, adhering to the highest standards of data protection.':
        'Introducing our cutting-edge application, designed with a comprehensive set of features to enhance user experience and security. Our app offers a seamless registration and login process, ensuring a smooth start for new users. With robust user account management, users can effortlessly control their personal information and settings, including password resets and customization preferences.\n\nFor a premium experience, we provide a membership subscription service that eliminates advertisements, supporting our monetization efforts. Key management is simplified, allowing users to add, select, and remove encryption keys with ease. Our app empowers users to encrypt and decrypt both single and batch files, ensuring their data is always protected. Activity history is meticulously recorded, giving users a clear overview of their encryption and decryption activities.\n\nWe understand the importance of a user-friendly interface, which is why our app is designed with usability in mind, requiring minimal training for effective navigation. Performance is a cornerstone of our app, with swift responsiveness and efficient load handling across various scenarios. Scalability is also a key feature, allowing our app to grow with our user base without compromising performance.\n\nSecurity is at the heart of our app, with robust measures in place to protect against unauthorized access and data breaches, adhering to the highest standards of data protection.',
    'Pick a color!': 'Pick a color!',
    'The key must be letters or numbers.':
        'The key must be letters or numbers.',
    'Got it': 'Got it',
    'Welcome to Login': 'Welcome to Login',
    'email:': 'email:',
    'Please input email': 'Please input email',
    'Please input password': 'Please input password',
    'Welcome to register': 'Welcome to register',
    'Repeat password': 'Repeat password',
    'Please re-enter the password to confirm':
        'Please re-enter the password to confirm',
    'Your membership will not be refund.\n\nYou may use the same email to register new account once deleted.':
        'Your membership will not be refund.\n\nYou may use the same email to register new account once deleted.',
    'Account Status': 'Account Status',
    'Until': 'Until',
    'Free Plan': 'Free Plan',
    'Downgrade': 'Downgrade',
    'Premium': 'Premium',
    'Selected': 'Selected',
    'Delete': 'Delete',
    'View': 'View',
    'type': 'type',
    'originDir': 'originDir',
    'originFile': 'originFile',
    'destDir': 'destDir',
    'destFile': 'destFile',
    'algorithm': 'algorithm',
    'dateTime': 'dateTime',
    'key name': 'key name',
    'Select fileType': 'Select fileType',
    'encrypt failed':'encrypt failed',
    'decrypt failed':'decrypt failed',
  };

  static Map<String, String> zh = {
    'My': '我的',
    'Account Management': '账户管理',
    'Key Management': '秘钥管理',
    'MemberShip Management': '会员管理',
    'language': '语言',
    'Theme': '主题色',
    'About': '关于',
    'Log out': '退出登录',
    'Log out success': '退出登录成功',
    'History List': '历史列表',
    'History Detail': '历史详情',
    'Select Language': '选择语言',
    'English': '英文',
    'Chinese': '中文',
    'Authentication failure': '认证失败',
    'Add Key': '新增秘钥',
    'Please enter a key': '请输入秘钥',
    'Please enter a name': '请输入名称',
    'New Secret Key': '新秘钥',
    'New Name': '新名称',
    'copy success': '复制成功',
    'Register': '注册',
    'Login': '登录',
    'Reset Password': '重置密码',
    'Main Page': '主页面',
    'Encrypt': '加密',
    'Decrypt': '解密',
    'Single File': '单选',
    'Batch File': '多选',
    'Next Step': '下一步',
    'finish': '完成',
    'Start': '开始',
    'index': '首页',
    'history': '历史',
    'my': '我的',
    'Please select the file first': '请先选择文件',
    'Please select one key first': '请先选择一个秘钥',
    'Select files': '选择文件',
    'Delete Account': '删除账户',
    'Cancel': '取消',
    'Confirm': '确认',
    'Random generation': '随机生成',
    'The key must contain 16 characters': '秘钥长度必须为16个字符',
    'Please select a key': '请选择一个秘钥',
    'Select key': '选择秘钥',
    'Select algorithm': '选择算法',
    'Introducing our cutting-edge application, designed with a comprehensive set of features to enhance user experience and security. Our app offers a seamless registration and login process, ensuring a smooth start for new users. With robust user account management, users can effortlessly control their personal information and settings, including password resets and customization preferences.\n\nFor a premium experience, we provide a membership subscription service that eliminates advertisements, supporting our monetization efforts. Key management is simplified, allowing users to add, select, and remove encryption keys with ease. Our app empowers users to encrypt and decrypt both single and batch files, ensuring their data is always protected. Activity history is meticulously recorded, giving users a clear overview of their encryption and decryption activities.\n\nWe understand the importance of a user-friendly interface, which is why our app is designed with usability in mind, requiring minimal training for effective navigation. Performance is a cornerstone of our app, with swift responsiveness and efficient load handling across various scenarios. Scalability is also a key feature, allowing our app to grow with our user base without compromising performance.\n\nSecurity is at the heart of our app, with robust measures in place to protect against unauthorized access and data breaches, adhering to the highest standards of data protection.':
        '欢迎体验我们的前沿应用程序，它配备了全面的特性能增强用户体验和安全性。我们的应用程序提供流畅的注册和登录流程，确保新用户能够轻松上手。通过强大的用户账号管理，用户可以轻松控制他们的个人信息和设置，包括密码重置和个性化偏好。\n\n为了提供高级体验，我们提供了会员订阅服务，消除广告，支持我们的盈利努力。密钥管理变得简单，允许用户轻松添加、选择和删除加密密钥。我们的应用程序使用户能够加密和解密单个和批量文件，确保他们的数据始终受到保护。活动历史被详细记录，让用户清晰地了解他们的加密和解密活动。\n\n我们理解用户友好界面的重要性，这就是为什么我们的应用程序以易用性为设计理念，用户可以快速上手。性能是我们应用程序的基石，具有快速响应能力和在各种场景下高效处理负载的能力。可扩展性也是我们应用程序的关键特性，允许我们的应用程序随着用户基础的增长而扩展，而不会降低性能。\n\n安全性是我们应用程序的核心，我们采取了强有力的措施来保护用户免受未授权访问和数据泄露的风险，遵循最高标准的数据处理保护。',
    'Pick a color!': '选择一个颜色',
    'Got it': '就是它',
    'Welcome to Login': '欢迎登录',
    'email:': '邮箱:',
    'Please input email': '请输入邮箱',
    'Please input password': '请输入密码',
    'Welcome to register': '欢迎注册账号',
    'Repeat password': '重复密码',
    'Please re-enter the password to confirm': '请重新确认输入密码',
    'Your membership will not be refund.\n\nYou may use the same email to register new account once deleted.':
        '您的会员将不获退款。\n\n删除后，您可以使用相同的电子邮件注册新帐户。',
    'Account Status': '账户状态',
    'Until': '截止时间',
    'Free Plan': '免费',
    'Downgrade': '降级',
    'Premium': '会员',
    'Selected': '升级',
    'Delete': '删除',
    'View': '详情',
    'type': '类型',
    'originDir': '来源目录',
    'originFile': '来源文件',
    'destDir': '目标目录',
    'destFile': '目标文件',
    'algorithm': '算法',
    'dateTime': '日期',
    'key name': '秘钥名称',
    'The key must be letters or numbers.': '秘钥必须为字母或数字',
    'Select fileType':'选择文件类型',
    'encrypt failed':'加密失败',
    'decrypt failed':'解密失败',
  };
}
